package cn.iocoder.yudao.module.wine.dal.mysql.memberdeadline;

import cn.iocoder.yudao.framework.common.pojo.PageResult;
import cn.iocoder.yudao.framework.mybatis.core.mapper.BaseMapperX;
import cn.iocoder.yudao.framework.mybatis.core.query.MPJLambdaWrapperX;
import cn.iocoder.yudao.module.member.dal.dataobject.user.MemberUserDO;
import cn.iocoder.yudao.module.wine.dal.dataobject.memberdeadline.MemberDeadlineDO;
import org.apache.ibatis.annotations.Mapper;
import cn.iocoder.yudao.module.wine.controller.admin.memberdeadline.vo.*;

/**
 * 会员期限 Mapper
 *
 * @author 管理员
 */
@Mapper
public interface MemberDeadlineMapper extends BaseMapperX<MemberDeadlineDO> {

    default PageResult<MemberDeadlineRespVO> selectPage(MemberDeadlinePageReqVO reqVO) {
        return selectJoinPage(reqVO, MemberDeadlineRespVO.class,  new MPJLambdaWrapperX<MemberDeadlineDO>()
                .eqIfPresent(MemberDeadlineDO::getUserId, reqVO.getUserId())
                .eqIfPresent(MemberDeadlineDO::getMemberTypeId, reqVO.getMemberTypeId())
                .betweenIfPresent(MemberDeadlineDO::getCreateTime, reqVO.getCreateTime())
                .leftJoin(MemberUserDO.class,MemberUserDO::getId,MemberDeadlineDO::getUserId)
                .selectAll(MemberDeadlineDO.class)
                .selectAs(MemberUserDO::getNickname, MemberDeadlineRespVO::getNickname)
                .selectAs(MemberUserDO::getName, MemberDeadlineRespVO::getName)
                .selectAs(MemberUserDO::getMobile, MemberDeadlineRespVO::getMobile)
                .orderByDesc(MemberDeadlineDO::getId));
    }

}
